package com.itheima.patterns.builderpattern.prototype.deepcopy;

import java.io.Serializable;

public class Person implements Cloneable, Serializable {
    private int id;
    private String name;
    private Address address;
    
    public String getName() {
        return name;
    }
    
    public Person(int id, String name, Address address) {
        this.id = id;
        this.name = name;
        this.address = address;
        System.out.println("具体的原型对象创建完成！");
    }
    
    @Override
    protected Object clone() throws CloneNotSupportedException {
        System.out.println("具体原型复制成功！");
        return (Person)super.clone();
    }
    
    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", address=" + address +
                '}';
    }
    
}